<?php 
/*bindParam方法绑定参数，与prepare、execute函数配合使用*/
/*
	在例子中我们可以看到采用占位名称进行定义，在使用bindparam方法时使用了“ bindParam(":占位名称", $a); ”
*/

try{
	$pdo = new PDO('mysql:host=localhost; dbname=exercise', 'root', 'root');
	$sql = "insert into user(username,password,email) values(:username,:password,:email)";
	$stmt = $pdo -> prepare($sql);
	$stmt -> bindParam(":username", $username);
	$stmt -> bindParam(":password", $password);
	$stmt -> bindParam(":email", $email);
	$username = "mengxianhui1";
	$password = "mengxianhui1";
	$email = "mengxianhui1@mxh.com";
	$stmt -> execute();
	echo $stmt->rowCount();

	$username = "mengxianhui2";
	$password = "mengxianhui2";
	$email = "mengxianhui2@mxh.com";
	$stmt -> execute();
	echo $stmt->rowCount();

}catch(PDEOxception $e) {
	echo $e->getMessage();
} 

 ?>